$(function(){
	var tcN=parseInt($("#tcNum").html());
	var tcV=parseInt($("#tcValue").val());
	$("#tcNum").html(tcN-tcV);
	
	var tmN=parseInt($("#tmNum").html());
	var tmV=parseInt($("#tmValue").val());
	$("#tmNum").html(tmN-tmV);
	
	var toN=parseInt($("#toNum").html());
	var toV=parseInt($("#toValue").val());
	$("#toNum").html(toN-toV);
	
})


function tcAdd(){
	var sId=$("#scenicId").val();
	var tcN=parseInt($("#tcNum").html());
	var tcV=parseInt($("#tcValue").val()); 
	var sum=tcV+tcN;
	if(tcV==sum){
		alert("没票了，兄dei");
	}else{
	var url="/Travel/ShopCarController?action=addCount&scenicId="+sId+"&tcCount=1";
	$.get(url,function(){
		location.href="/Travel/shopcar/success.jsp";
	})
	}
}



function tcDiff(){
	var sId=$("#scenicId").val();
	var tcN=parseInt($("#tcNum").html());
	var tcV=parseInt($("#tcValue").val()); 
	var sum=tcV+tcN;
	if(tcV==0){
		alert("兄dei，上车");
	}else{
	var url="/Travel/ShopCarController?action=diffCount&scenicId="+sId+"&tcCount=-1";
	$.get(url,function(){
		location.href="/Travel/shopcar/success.jsp";
	})
	}
}


function toAdd(){
	var sId=$("#scenicId").val();
	var toN=parseInt($("#toNum").html());
	var toV=parseInt($("#toValue").val()); 
	var sum=toV+toN;
	if(toV==sum){
		alert("没票了，兄dei");
	}else{
	var url="/Travel/ShopCarController?action=addCount&scenicId="+sId+"&toCount=1";
	$.get(url,function(){
		location.href="/Travel/shopcar/success.jsp";
	})
	}
}



function toDiff(){
	var sId=$("#scenicId").val();
	var toN=parseInt($("#toNum").html());
	var toV=parseInt($("#toValue").val()); 
	var sum=toV+toN;
	if(toV==0){
		alert("兄dei，上车");
	}else{
	var url="/Travel/ShopCarController?action=diffCount&scenicId="+sId+"&toCount=-1";
	$.get(url,function(){
		location.href="/Travel/shopcar/success.jsp";
	})
	}
}





function tmAdd(){
	var sId=$("#scenicId").val();
	var tmN=parseInt($("#tmNum").html());
	var tmV=parseInt($("#tmValue").val()); 
	var sum=tmV+tmN;
	if(tmV==sum){
		alert("没票了，兄dei");
	}else{
	var url="/Travel/ShopCarController?action=addCount&scenicId="+sId+"&tmCount=1";
	$.get(url,function(){
		location.href="/Travel/shopcar/success.jsp";
	})
	}
}



function tmDiff(){
	var sId=$("#scenicId").val();
	var tmN=parseInt($("#tmNum").html());
	var tmV=parseInt($("#tmValue").val()); 
	var sum=tmV+tmN;
	if(tmV==0){
		alert("兄dei，上车");
	}else{
	var url="/Travel/ShopCarController?action=diffCount&scenicId="+sId+"&tmCount=-1";
	$.get(url,function(){
		location.href="/Travel/shopcar/success.jsp";
	})
	}
}


function shopClear(){
	 var url="/Travel/ShopCarController?action=clear";
	$.get(url,function(){
		location.href="/Travel/shopcar/success.jsp";
	}) 
}

function deleteScenic(tickitType,scenicId){
	var url="/Travel/ShopCarController?action=deleteScenic&scenicId="+scenicId+"&tickitType="+tickitType;
	$.get(url,function(){
		location.href="/Travel/shopcar/success.jsp";
	})
}

function pay(){

	var userId=$("#userinfoId").val();
	var url="/Travel/UserinfoController?action=pay&userId="+userId;
	$.get(url,function(mes){
		alert(mes);
	});
	shopClear();
}